class TimelineEvent {
  final String id;
  final String title;
  final String description;
  final DateTime date;
  final String category;
  final String emoji;
  final List<String> imagePaths;
  final String author; // 新增发布人字段

  TimelineEvent({
    required this.id,
    required this.title,
    required this.description,
    required this.date,
    required this.category,
    required this.emoji,
    this.imagePaths = const [],
    this.author = '👩', // 默认作者
  });

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'title': title,
      'description': description,
      'date': date.toIso8601String(),
      'category': category,
      'emoji': emoji,
      'imagePaths': imagePaths,
      'author': author,
    };
  }

  factory TimelineEvent.fromJson(Map<String, dynamic> json) {
    return TimelineEvent(
      id: json['id'],
      title: json['title'],
      description: json['description'],
      date: DateTime.parse(json['date']),
      category: json['category'],
      emoji: json['emoji'],
      imagePaths: List<String>.from(json['imagePaths'] ?? []),
      author: json['author'] ?? '👩', // 兼容旧数据
    );
  }
}